package com.fengke.dao.product.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.fengke.dao.BaseDaoIbatis;
import com.fengke.dao.model.AdminStoryModel;
import com.fengke.dao.model.DepartureModel;
import com.fengke.dao.model.DestinationModel;
import com.fengke.dao.model.PriceItemModel;
import com.fengke.dao.model.ProductImageModel;
import com.fengke.dao.model.ProductItemModel;
import com.fengke.dao.model.ProductModel;
import com.fengke.dao.model.ProductCategoryModel;
import com.fengke.dao.model.ProductTagModel;
import com.fengke.dao.product.ProductManager;

public class ProductManagerImpl extends BaseDaoIbatis implements ProductManager {

	@SuppressWarnings("unchecked")
	public List<ProductModel> researchProductList(ProductModel productModel, int offset, int limit) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchProductList", productModel, offset, limit);
	}

	public Integer researchProductListSize(ProductModel productModel) throws SQLException {
		return (Integer) this.getSqlMapClientTemplate().queryForObject("ProductRepository.researchProductListSize", productModel);
	}

	public int deleteProductByIds(List<String> list) throws SQLException {
		return this.getSqlMapClientTemplate().delete("ProductRepository.deleteProductModelByIds", list);
	}

	public Object createProduct(ProductModel productModel) throws SQLException {
		return this.getSqlMapClientTemplate().insert("ProductRepository.createProductModel", productModel);
	}

	public ProductModel researchProductById(ProductModel productModel) throws SQLException {
		return (ProductModel) this.getSqlMapClientTemplate().queryForObject("ProductRepository.researchProductById", productModel);
	}

	public int updateProductById(ProductModel productModel) throws SQLException {
		return this.getSqlMapClientTemplate().update("ProductRepository.updateProductModelById", productModel);
	}

	@SuppressWarnings("unchecked")
	public List<ProductCategoryModel> researchProductCategoryList(ProductCategoryModel productCategory, int offset, int limit) {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchProductCategoryList", productCategory, offset, limit);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ProductCategoryModel> researchProductCategoryListByOnlineProduct(ProductModel productModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchProductCategoryListByOnlineProduct", productModel);
	}

	public Object createProductItem(ProductItemModel productItemModel) throws SQLException {
		return this.getSqlMapClientTemplate().insert("ProductRepository.createProductItemModel", productItemModel);
	}

	public Object createAdminStory(AdminStoryModel adminStoryModel) throws SQLException {
		return this.getSqlMapClientTemplate().insert("ProductRepository.createAdminStoryModel", adminStoryModel);
	}

	public int deleteProductItemByProductIds(List<String> list) throws SQLException {
		return this.getSqlMapClientTemplate().delete("ProductRepository.deleteProductItemModelByProductIds", list);
	}

	public int deleteAdminStoryByProductIds(List<String> list) throws SQLException {
		return this.getSqlMapClientTemplate().delete("ProductRepository.deleteAdminStoryModelByProductIds", list);
	}

	@SuppressWarnings("unchecked")
	public List<ProductItemModel> researchProductItemList(ProductItemModel productItemModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchProductItemList", productItemModel);
	}

	@SuppressWarnings("unchecked")
	public List<AdminStoryModel> researchAdminStoryList(AdminStoryModel adminStoryModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchAdminStoryList", adminStoryModel);
	}

	public int updateProductItemById(ProductItemModel productItemModel) throws SQLException {
		return this.getSqlMapClientTemplate().update("ProductRepository.updateProductItemModelById", productItemModel);
	}

	public int updateAdminStoryById(AdminStoryModel adminStoryModel) throws SQLException {
		return this.getSqlMapClientTemplate().update("ProductRepository.updateAdminStoryModelById", adminStoryModel);
	}

	public int deleteProductImageByProductIds(List<String> list) throws SQLException {
		return this.getSqlMapClientTemplate().delete("ProductRepository.deleteProductImageModelByProductIds", list);
	}

	@SuppressWarnings("unchecked")
	public List<ProductImageModel> researchProductImageList(ProductImageModel productImageModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchProductImageList", productImageModel);
	}

	public void createProductImage(ProductImageModel productImageModel) throws SQLException {
		this.getSqlMapClientTemplate().insert("ProductRepository.createProductImageModel", productImageModel);
	}

	@Override
	public Long createProductCategory(ProductCategoryModel productCategoryModel) throws SQLException {
		return (Long) this.getSqlMapClientTemplate().insert("ProductRepository.createProductCategory", productCategoryModel);
	}

	@Override
	public int updateProductCategoryById(ProductCategoryModel productCategoryModel) throws SQLException {
		return this.getSqlMapClientTemplate().update("ProductRepository.updateProductCategoryById", productCategoryModel);
	}

	@Override
	public int deleteProductCategoryByIds(List<String> list) throws SQLException {
		return this.getSqlMapClientTemplate().delete("ProductRepository.deleteProductCategoryByIds", list);
	}

	@Override
	public int marketableProductByIds(Map<String, Object> paramMap) throws SQLException {
		return this.getSqlMapClientTemplate().update("ProductRepository.marketableProductByIds", paramMap);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<DepartureModel> researchDepartureListByOnlineProduct(ProductModel productModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchDepartureListByOnlineProduct", productModel);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<DestinationModel> researchDestinationListByOnlineProduct(ProductModel productModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchDestinationListByOnlineProduct", productModel);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<String> researchStartDateListByOnlineProduct(ProductModel productModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchStartDateListByOnlineProduct", productModel);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<PriceItemModel> researchPriceItemList(PriceItemModel priceItemModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchPriceItemList", priceItemModel);
	}

	@Override
	public Long createPriceItem(PriceItemModel priceItemModel) throws SQLException {
		return (Long) this.getSqlMapClientTemplate().insert("ProductRepository.createPriceItemModel", priceItemModel);
	}

	@Override
	public int deletePriceItemByProductIds(List<String> list) throws SQLException {
		return this.getSqlMapClientTemplate().delete("ProductRepository.deletePriceItemByProductIds", list);
	}

	@Override
	public void createProductTag(ProductTagModel productTagModel) throws SQLException {
		this.getSqlMapClientTemplate().insert("ProductRepository.createProductTag", productTagModel);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ProductTagModel> researchProductTagListByProductId(ProductTagModel productTagModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("ProductRepository.researchProductTagListByProductId", productTagModel);
	}

	@Override
	public int deleteProductTagByProductIds(List<String> list) throws SQLException {
		return this.getSqlMapClientTemplate().delete("ProductRepository.deleteProductTagByProductIds", list);
	}
}
